package com.zjy.dao;

import com.zjy.entity.Book;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import javax.transaction.Transactional;
import java.util.List;

public interface BookRepository extends JpaRepository<Book, Integer> {
    Book findByAuthorAndStatus(String author, String status);

    @Modifying
    @Transactional
    @Query("delete from Book b where b.id=:id")
    List<Book> deleteBookById(@Param("id") Integer id);
}
